package com.airforce.mappers;

import com.airforce.model.region;
import org.apache.ibatis.jdbc.SQL;

public class regionSqlProvider {

    public String insertSelective(region record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("region");
        
        if (record.getId() != null) {
            sql.VALUES("Id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("Name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getParentid() != null) {
            sql.VALUES("ParentId", "#{parentid,jdbcType=INTEGER}");
        }
        
        if (record.getShortname() != null) {
            sql.VALUES("ShortName", "#{shortname,jdbcType=VARCHAR}");
        }
        
        if (record.getLeveltype() != null) {
            sql.VALUES("LevelType", "#{leveltype,jdbcType=INTEGER}");
        }
        
        if (record.getCitycode() != null) {
            sql.VALUES("CityCode", "#{citycode,jdbcType=VARCHAR}");
        }
        
        if (record.getZipcode() != null) {
            sql.VALUES("ZipCode", "#{zipcode,jdbcType=VARCHAR}");
        }
        
        if (record.getMergername() != null) {
            sql.VALUES("MergerName", "#{mergername,jdbcType=VARCHAR}");
        }
        
        if (record.getLng() != null) {
            sql.VALUES("Lng", "#{lng,jdbcType=REAL}");
        }
        
        if (record.getLat() != null) {
            sql.VALUES("Lat", "#{lat,jdbcType=REAL}");
        }
        
        if (record.getPinyin() != null) {
            sql.VALUES("Pinyin", "#{pinyin,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(region record) {
        SQL sql = new SQL();
        sql.UPDATE("region");
        
        if (record.getName() != null) {
            sql.SET("Name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getParentid() != null) {
            sql.SET("ParentId = #{parentid,jdbcType=INTEGER}");
        }
        
        if (record.getShortname() != null) {
            sql.SET("ShortName = #{shortname,jdbcType=VARCHAR}");
        }
        
        if (record.getLeveltype() != null) {
            sql.SET("LevelType = #{leveltype,jdbcType=INTEGER}");
        }
        
        if (record.getCitycode() != null) {
            sql.SET("CityCode = #{citycode,jdbcType=VARCHAR}");
        }
        
        if (record.getZipcode() != null) {
            sql.SET("ZipCode = #{zipcode,jdbcType=VARCHAR}");
        }
        
        if (record.getMergername() != null) {
            sql.SET("MergerName = #{mergername,jdbcType=VARCHAR}");
        }
        
        if (record.getLng() != null) {
            sql.SET("Lng = #{lng,jdbcType=REAL}");
        }
        
        if (record.getLat() != null) {
            sql.SET("Lat = #{lat,jdbcType=REAL}");
        }
        
        if (record.getPinyin() != null) {
            sql.SET("Pinyin = #{pinyin,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("Id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}